//
//  XTmyDairyDetailsViewController.m
//  BeautifulHome
//
//  Created by dlios on 15-7-13.
//  Copyright (c) 2015年 ACE. All rights reserved.
//

#import "XTmyDairyDetailsViewController.h"

@interface XTmyDairyDetailsViewController ()
@property(nonatomic, retain)UILabel *titleLabel;
@property(nonatomic, retain)UILabel *commentLabel;
@end

@implementation XTmyDairyDetailsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"我的日记";
    self.navigationController.navigationBar.translucent = NO;
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
    imageView.image = [UIImage imageNamed:@"999b"];
    [self.view addSubview:imageView];
    [self xiangQiang];
    
    
}
+ (CGFloat)heightWithText:(NSString *)text
{
    //设置一个字典保存文本属性
    NSDictionary *dic =[ NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:17],NSFontAttributeName, nil];
    //NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:17]};
    
    //预设一个尺寸  文本最大不会超过这个尺寸
    CGSize size = CGSizeMake(375, 2000);
    //根据文本信息获得一个CGRect
    //参数1: 尺寸范围
    //参数2: 文本属性
    //参数3: 按照什么方式获取Rect
    //参数4: nil
    CGRect rect = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    //返回得到的高度
    return rect.size.height;
}
- (void)xiangQiang
{
    CGFloat f = [[self class]heightWithText:_titleName];
    //标题
    UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, self.view.frame.size.width - 20, f)];
    NSString *str = [NSString stringWithFormat:@"    %@",_titleName];
    label1.text = str;
    [label1 setLineBreakMode:NSLineBreakByCharWrapping];
    label1.numberOfLines = 0;
    label1.backgroundColor = [UIColor clearColor];
    [self.view addSubview:label1];
    [label1 release];
    
    CGFloat f1 = [[self class]heightWithText:_commentName];
    //内容
    UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(10, f + 20, self.view.frame.size.width - 20, f1)];
    NSString *str1 = [NSString stringWithFormat:@"  %@",_commentName];
    label2.text = str1;
    [label2 setLineBreakMode:NSLineBreakByCharWrapping];
    label2.numberOfLines = 0;
    label2.backgroundColor = [UIColor clearColor];
    [self.view addSubview:label2];
    [label2 release];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
